package com.ideaaedi.zoo.example.springboot.seata_sharding.beta.controller;

import com.ideaaedi.zoo.example.springboot.seata_sharding.beta.service.BizShardingService;
import io.seata.core.context.RootContext;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试入口在service-alpha的controller中
 */
@RestController
@RequestMapping("/beta")
@Hidden
public class BetaController {
    
    @Resource
    private BizShardingService bizShardingService;
    
    @Resource
    private HttpServletRequest httpServletRequest;
    
    @GetMapping("/insert-some-data")
    public void insertSomeBetaData() {
        String xid = httpServletRequest.getHeader(RootContext.KEY_XID);
        System.err.println("全局事务id传递过来啦：" + xid);
        bizShardingService.insertSomeShardingData();
    }
}
